import Vue from 'vue'
import VueRouter from 'vue-router'
import About from '../views/About.vue'
import store from "../store/index"
Vue.use(VueRouter)

const routes = [
  {
    path: '/about',
    component: About,
    children:[
      {
        path: 'home',
        component: () => import(/* webpackChunkName: "smoll" */ '../views/Home.vue')
      },
      {
        path: 'allGoods',
        component: () => import(/* webpackChunkName: "smoll" */ '../views/AllGoods.vue')
      },
      {
        path: 'aboutUs',
        component: () => import(/* webpackChunkName: "smoll" */ '../views/AboutUs.vue')
      },
      {
        path: 'details',
        component: () => import(/* webpackChunkName: "smoll" */ '../views/Details.vue')
      },
      {
        path:'collect',
        component: () => import(/* webpackChunkName: "smoll" */ '../views/Collect.vue')
      },
      {
        path:'shopping',
        component: () => import(/* webpackChunkName: "smoll" */ '../views/Shopping.vue')
      },
      {
        path:'order',
        component: () => import(/* webpackChunkName: "smoll" */ '../views/Order.vue')
      },
      {
        path:'confirmorder',
        component: () => import(/* webpackChunkName: "smoll" */ '../views/ConFirmOrder.vue')
      },
      {
        path:'/about',
        redirect:'/about/home'
      }
    ]
  },
  {
    path:'/',
    redirect:"/about"
  },
]

const router = new VueRouter({
  routes
})
// router.beforeEach(function(to,from,next){
//   if(to.path == '/about/shopping'||'/about/order'||'/about/collect'){
//     if(store.state.user !== null){
//       next()
//     }else{
//       store.commit("setlogin")
//       next('/about/home')
//     }
//   }else{
//     next()
//   }
// })
export default router
